package waal.pc.backend.channels;


import waal.pc.backend.dataPoints.AnalogDataPoint;
import waal.pc.backend.module.Module;

public class AnalogChannel extends Channel {

	private AnalogDataPoint lastValue = new AnalogDataPoint(0,0);
	
	public AnalogChannel(Module module, int number, String name, boolean input) {
		super(module, number, name, input, false);
		module.fireChannelEvent(new ChannelEvent(1, this));
	}
	
	public AnalogChannel(Module module, int number, String name) {
		this(module, number,name, true);
	}
	
	public void addValue(double time, double value) {
		AnalogDataPoint p = new AnalogDataPoint(time, value);
		this.lastValue = p;
		this.addDataForChannelDataListener(p);
		this.fireChannelChange();
	}
	
	public void setValue(double value) {
		AnalogDataPoint p = new AnalogDataPoint(0, value);
		this.lastValue = p;
		this.fireChannelChange();
	}
	
	public AnalogDataPoint getLastData() {
		return this.lastValue;
	}
	
	public double getLastValue() {
		return this.lastValue.getValue();
	}

}
